<template>
  <div class="my-counter">
    <Button type="warning" class="btn btn-light" @click="changeCount('minus')">-</Button>
    <input type="number" class="form-control inp" v-model="Count">
    <Button type="primary" class="btn btn-light" @click="changeCount('add')">+</Button>
  </div>
</template>

<script>
export default {
    name:'MyCount',
    props:['id','goods_count'],
    data(){
        return {

        }
    },
    methods:{
        changeCount(isAddOrMinus){
            if(isAddOrMinus=='add'){
                 this.$emit('changeCount','add',this.id)
            }else{
                if(this.goods_count<=1) return;
                   this.$emit('changeCount','minus',this.id)
            }
        }
    },
    computed:{
        Count:{
            set(){
                this.$emit('changeCountNum',this.Count,this.id)
            },
            get(){
                return this.goods_count
            }
        }
    }
}
</script>

<style lang="less" scoped>
.my-counter {
  display: flex;
  .inp {
    width: 45px;
    text-align: center;
    margin: 0 10px;
  }
  .btn, .inp{
    transform: scale(0.9);
  }
}
</style>